#include "ModeControlDialog.h"
#include "ui_ModeControlDialog.h"
#include "ClassDataBaseWindow.h"
#include <EDesignerCore.h>
#include <iostream>
#include <ResourceWindow.h>
ModeControlDialog::ModeControlDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ModeControlDialog)
{
    ui->setupUi(this);
    ui->tabWidget->removeTab(0);
    ui->tabWidget->removeTab(0);

    QObject::connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
    QObject::connect(ui->pushButton_2, SIGNAL(clicked(bool)), this, SLOT(reject()) );

}

ModeControlDialog::~ModeControlDialog()
{
    delete ui;
}

QString ModeControlDialog::enterSelectClassTypeMode()
{
    EDesignerCore::instance()->classDataBaseWindow()->refreshTreeWidget();
    ui->tabWidget->addTab(EDesignerCore::instance()->classDataBaseWindow(), "Select Class Type");
    int dialog_code = this->exec();
    QString class_type = "-1";
    if(dialog_code == 1)
    {
        class_type = EDesignerCore::instance()->classDataBaseWindow()->currentClassType();
    }
    EDesignerCore::instance()->classDataBaseWindow()->reDock();
    return class_type;
}

QString ModeControlDialog::enterSelectResourceMode()
{
    ui->tabWidget->addTab(EDesignerCore::instance()->resourceWindow(), "Select Resource");
    int dialog_code = this->exec();
    QString resourceFileName;
    if(dialog_code == 1)
    {
        resourceFileName = EDesignerCore::instance()->resourceWindow()->getCurrentFilePath();
    }
    EDesignerCore::instance()->resourceWindow()->reDock();
    return resourceFileName;
}
